package com.ruoyi.web.controller.saleManagement;

import com.ruoyi.common.annotation.RateLimiter;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.vo.MessageVo;
import com.ruoyi.system.service.MessageService;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;


/**
 * @author YiYuan
 * @description 售后反馈
 * @date 2023/12/8
 */
@RestController
@RequestMapping("/saleManagement/message")
@RequiredArgsConstructor
public class SaleMessageController {
    private static final Logger log = LoggerFactory.getLogger(SaleMessageController.class);
    private final MessageService messageService;

    @GetMapping("/getFeedBackCount")
    @RateLimiter(time = 30, count = 100)
    public AjaxResult getFeedBackCount(){
        return messageService.getFeedBackCount();
    }

    //获取车辆反馈信息
    @GetMapping("/list")
    @RateLimiter(time = 30, count = 100)
    public AjaxResult list(String carId, int pageNum, int pageSize)
    {
        return messageService.getFeedBackLastMessage(carId, pageNum, pageSize);
    }

    /**
     * 永久删除车辆ID
     * @param carId 车辆ID
     * @return
     */
    @DeleteMapping("/removeFeedBack")
    @RateLimiter(time = 30, count = 100)
    public AjaxResult removeFeedBack(String carId)
    {
        return messageService.removeFeedBack(carId);
    }

    //管理人员回复
    @PostMapping("/reply")
    public void reply(@RequestParam("carId") String carId, @RequestBody MessageVo messageVo){
        messageService.reply(carId, messageVo);
    }
}
